package com.dingding.webservice.account.impl;

import java.util.List;

import com.dingding.bean.databean.request.ReqGetUserIntegralDetail;
import com.dingding.bean.databean.response.DataResponse;
import com.dingding.common.core.beans.Userintegraldetail;
import com.dingding.common.core.config.SystemCode;
import com.dingding.common.core.util.ToolUtil;
import com.dingding.facade.account.integral.dto.GetUserIntegralDetailDTO;
import com.dingding.service.BaseService;
import com.dingding.webservice.account.IIntegralService;

/**
 * @ClassName: UserIntegralServiceImpl
 * @Description: 用户积分操作服务接口实现
 * 积分添加、删除、修改
 * @author yuHaiQing
 * @date 2016年4月7日 下午6:23:20
 */
public class IntegralServiceImpl extends BaseService implements IIntegralService {

	/**
	 * @Title: getUserIntegralDetail
	 * @Description: 获取用户积分交易明细
	 * @param reqGetUserIntegralDetail 数据传输BEAN
	 * @author yuHaiQing
	 * @return void
	 */
	@Override
	public void getUserIntegralDetail(ReqGetUserIntegralDetail reqGetUserIntegralDetail, DataResponse dataResponse) {
		
		//判断请求参数是否为空
		if(reqGetUserIntegralDetail == null
				|| ToolUtil.isBlank(reqGetUserIntegralDetail.getUserId())
				|| reqGetUserIntegralDetail.getPageSize() == null
				|| reqGetUserIntegralDetail.getRow() == null){
			
			setStatus(dataResponse, SystemCode.DATA_NULL_ERROR);
			return;
		}
		
		GetUserIntegralDetailDTO getUserIntegralDetailDTO = new GetUserIntegralDetailDTO();
		
		//用户Id
		getUserIntegralDetailDTO.setUserId(reqGetUserIntegralDetail.getUserId());
		//当前页
		getUserIntegralDetailDTO.setPageSize(reqGetUserIntegralDetail.getPageSize());
		//每页显示记录数
		getUserIntegralDetailDTO.setRow(reqGetUserIntegralDetail.getRow());
		
		//获取用户交易明细列表
		List<Userintegraldetail> userintegraldetails = super.integralService.getUserIntegralDetail(getUserIntegralDetailDTO);
		
		//设置响应信息
		dataResponse.setResponseBody(userintegraldetails);

		//成功
		setStatus(dataResponse, SystemCode.SUCCESS);
	}

	
	@Override
	public void setStatus(DataResponse dataResponse, int status) {
		String message = null;
		switch (status) {
		case SystemCode.SUCCESS:
			message = SystemCode.SUCCESS_MESSAGE;
			break;
		case SystemCode.ERROR:
			message = SystemCode.ERROR_MESSAGE;
			break;
		case SystemCode.USER_INFO_NOT_EXIST_ERROR: // 用户信息不存在
			message = SystemCode.USER_INFO_NOT_EXIST_MESSAGE;
			break;
		case SystemCode.CANCEL_ORDER_TOO_MUCH: // 取消次数超过三次
			message = SystemCode.CANCEL_ORDER_MUCH_MESSAGE;
			break;
		case SystemCode.PUBLISH_ORDER_TOO_MUCH: // 接单次数超过三次
			message = SystemCode.PUBLISH_ORDER_TOO_MUCH_MESSAGE;
			break;
		case SystemCode.DATA_NULL_ERROR: // 请求数据为空
			message = SystemCode.DATA_NULL_MESSAGE;
			break;
		case SystemCode.COUPON_ACTIVATION_FAIL:
			message = SystemCode.COUPON_ACTIVATION_FAIL_MESSAGE;// 优惠券激活失败
			break;
		case SystemCode.STORE_LOAG_NULL:
			message = SystemCode.STORE_LOAD_NULL_MESSAGE;// 使用优惠券失败
			break;
		default:
			break;
		}
		dataResponse.setResponseCode(status);
		dataResponse.setResponseMessage(message);

	}


}
